package cn.jiangxiong.pethome.base.service.impl;

import cn.jiangxiong.pethome.base.mapper.BaseMapper;
import cn.jiangxiong.pethome.base.query.BaseQuery;
import cn.jiangxiong.pethome.base.service.IBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
public class BaseServiceImpl<T> implements IBaseService<T> {
    @Autowired
    private BaseMapper<T> baseMapper;

    @Override
    public T findOne(Long id) {
        return baseMapper.findOne(id);
    }

    @Override
    public List<T> findAll() {
        return baseMapper.findAll();
    }

    @Override
    public List<T> findByQuery(BaseQuery query) {
        return baseMapper.findByQuery(query);
    }

    @Override
    public Long findByQueryCount(BaseQuery query) {
        return baseMapper.findByQueryCount(query);
    }
    @Transactional
    @Override
    public void add(T t) {
       baseMapper.add(t);
    }
    @Transactional
    @Override
    public void update(T t) {
        baseMapper.update(t);
    }
    @Transactional
    @Override
    public void delete(Long id) {
          baseMapper.delete(id);
    }
    @Transactional
    @Override
    public void batchDel(List<Long> ids) {
       baseMapper.batchDel(ids);
    }
}
